WWL.gallery = function ( name )
{			
	var gallery;
	if  ( WWL.get_instance ( "gallery", name ) )
	{
		gallery =  WWL.get_instance ( "gallery", name )
	} else {
		gallery = new WWL ( 'gallery', name );
	}

	gallery._ie = ! liwe.utils.supports ( 'transition' );

	gallery.items = [];
	
	gallery.player_size = { w : 120, h : 120 };
	gallery.thumb_size = { w : 100, h : 50 };
	//{{{gallery.add_item = function ( src, alt, title, thumb_src, youtube , item )
	gallery.add_item = function ( src, alt, title, thumb_src, youtube , item )
	{
		if ( item instanceof gallery_img ) 
		{
			gallery.items.push ( item );
			return;
		}
		if ( !src ) return;
		if ( !thumb_src ) thumb_src = src;
		if ( !item )
		{
			var _youtube = null;
			if ( youtube ) _youtube = youtube
			item = new gallery_img ( src, alt, title, thumb_src , youtube);
			item.set_thumb_size ( gallery.thumb_size [ 'w' ], gallery.thumb_size [ 'h' ] )
			gallery.items.push ( item );
			return;
		}
		
	};
	//}}}
	//{{{gallery.set_thumb_size = function ( w, h )
	gallery.set_thumb_size = function ( w, h )
	{
		gallery.thumb_size = { w : w , h : h };
	};
	//}}}
	//{{{gallery.set_player_size = function ( w, h )
	gallery.set_player_size = function ( w, h )
	{
		gallery.player_size = { w : w , h : h };
	};
	//}}}
	//{{{gallery.render = function ( dest_div, cback )
	gallery.render = function ( dest_div, cback )
	{
		var _cnt, c;
		var offset = [ 'position', 'top', 'right', 'bottom', 'left' ]; 

		dest_div = $el ( dest_div );

		if ( ! dest_div ) return;
		dest_div.innerHTML = '';

		gallery.dest_div = dest_div;
		//gallery.dest_div._position = gallery.dest_div.style.position; 
		gallery.dest_div._position = {};
		for ( c = 0; c < offset.length; c += 1 )
		{
			gallery.dest_div._position [ offset [ c ] ] = liwe.dom.get_style ( gallery.dest_div, offset [ c ] );
		}

		gallery.dest_div._is_full = 0;
		gallery.dest_div._zindex = gallery.dest_div.style.zIndex;
		gallery._zindex_max = liwe.dom.get_highest_zindex() +  1;
	
		gallery.size = liwe.dom.get_size ( gallery.dest_div );
		
		gallery.img_current = undefined;

		gallery._switch_id = 0;

		var img_0 = gallery.items [ 0 ];
		img_0.width=gallery.size [ 0 ];
		img_0.height=gallery.size [ 1 ];
		img_0.id = gallery.name + '_img_0'; 

		//container
		gallery.container =  document.createElement ( 'div' );
		gallery.container.id = 'gallery_' +  gallery.name;
		gallery.container.className = 'gallery';
	//	liwe.events.add ( gallery.container , 'mousemove', function ( ev ) { gallery.show_controls ( ev );} );

		//imges
		gallery.images = document.createElement ( 'div' );
		gallery.images.id = "gallery_images_" + gallery.name;
		gallery.images.className = "gallery_images";
		gallery.images.style.width = gallery.size [ 0 ] + 'px';
		gallery.images.style.height = gallery.size [ 1 ] + 'px';

		// {{{ imgcnt 0 - 1
		gallery.imgcnt = [];
		for ( _cnt = 0; _cnt < 2; _cnt ++ )
		{
			var imgcnt = document.createElement ( 'div' );
			imgcnt.id =  gallery.name + '_imgcnt_' + _cnt;
			imgcnt.className = 'gallery_img';
			liwe.events.add ( imgcnt , 'mouseover', function ( ev ) { gallery.show_controls ( ev );} );
			gallery.imgcnt.push ( imgcnt );

			//var img = img_0.get_img ( null, gallery.img_caricata ) ;
			
			var img = document.createElement ( 'img' );
			liwe.events.add ( img , 'load', function () { gallery.img_caricata (img);} );


			img.id = gallery.name + '_img_' + _cnt;
			img.style.position = 'absolute';

			imgcnt.appendChild ( img );

			//liwe.events.add ( img, 'load',  function ( ev ) { gallery._switch ( ev ); } );
			gallery.images.appendChild ( imgcnt );
		};
		// }}}
		// {{{ controls
		gallery.controls = document.createElement ( 'div' );
		gallery.controls.id = "gallery_controls_" + gallery.name;
		gallery.controls.style.width = gallery.size [ 0 ] + 'px';
		//gallery.controls.style.maxWidth = gallery.size [ 0 ] + 'px';
		gallery.controls.style.height = gallery.size [ 1 ] + 'px';
		gallery.controls.className = "gallery_controls";
		// }}}
		// {{{ head
		gallery.head = document.createElement ( 'div' );
		gallery.head.className = 'gallery_head';
		// }}}
		// {{{ toggle full screen button
		gallery.set_screen = document.createElement ( 'div' );
		gallery.set_screen.className = 'gallery_set_screen full';
		gallery.head.appendChild ( gallery.set_screen );
		liwe.events.add ( gallery.set_screen, 'mousedown', function ( ev ) { gallery.toggle_full_screen ( ev ); } );
		// }}}
		// {{{ gallery info 1-2
		//info 1-2
		gallery.info = [];

		for ( var x = 0; x < 2; x ++ )
		{
			info_0 = document.createElement ( 'div' );
			info_0.className = 'gallery_info';
			info_0.id = gallery.name + '_info_' + x; 
			info_0.innerHTML = String.formatDict ( WWL.gallery.templates [ 'info' ] , 
					{
						'alt' : img_0.alt,
						'title' : img_0.title
					} );
			gallery.info.push ( info_0 );
			gallery.head.appendChild ( info_0 );
		}
		// }}}
		// {{{ thumb
		gallery.thumb_id = 'gallery_thumb_' + gallery.name ;
		gallery.thumb = document.createElement ( 'div' );
		gallery.thumb.id = gallery.thumb_id;
		gallery.thumb.className = 'gallery_thumb';
		// }}}
		// {{{ thumb tab
		
		gallery.thumb_tabcnt = document.createElement ( 'div' );
		gallery.thumb_tabcnt.className = 'gallery_thumb_tabcnt';
		gallery.thumb.appendChild ( gallery.thumb_tabcnt );

		gallery.thumb_tab = document.createElement ( 'div' );
		gallery.thumb_tab.className = 'gallery_thumb_tab down';
		liwe.events.add ( gallery.thumb_tab , 'mousedown', function ( ev ) { gallery.thumbnails ( ev );} );

		gallery.thumb_tabcnt.appendChild ( gallery.thumb_tab );
		// }}}
		// {{{ thumb list container
		gallery.thumb_arrow_id = 'gallery_thumb_arrow_' + gallery.name ;
		gallery.thumb_arrow = document.createElement ( 'div' );
		gallery.thumb_arrow.className = 'gallery_thumb_arrow';
		gallery.thumb_arrow.id = gallery.thumb_arrow_id; 
		gallery.thumb.appendChild ( gallery.thumb_arrow );
		// }}}
		// {{{ arrowbox thumb
		gallery.arrow_thumb = WWL.arrowbox.get_instance ( 'gallery_thumb_' + gallery.name );
		if ( gallery.arrow_thumb == undefined ) gallery.arrow_thumb = new WWL.arrowbox ( 'gallery_thumb_' + gallery.name ); 
		gallery.arrow_thumb.clear();
		gallery.arrow_thumb.set_size  ( gallery.size [ 0 ], gallery.thumb_size [ 'h' ]  );
		gallery.arrow_thumb.set_item_size  ( gallery.thumb_size [ 'w' ] , gallery.thumb_size [ 'h' ] );
		gallery.arrow_thumb.cbacks [ 'item-clicked' ] = function ( sb , elem ) {  gallery.display_item ( sb, elem ); };
		// }}}
		// {{{ add items to gallery
		var thumb = '';
		gallery.items.iterate ( function ( item, k )
		{
			//thumb = String.formatDict ( WWL.gallery.templates [ 'thumb' ] , { 'name' : gallery.name, 'id' : k , 'img' :  item.get_img_html ( true ) } );
			//gallery.arrow_thumb.add_item ( item.get_img_html ( true ) );
			gallery.arrow_thumb.add_item ( item.get_img_html ( true ) );
		});
		// }}}
		// {{{ controls arrow_prev and next video play
		gallery.prev = document.createElement ( 'div' );
		gallery.prev.className = 'gallery_prev';
		gallery.prev.style.top = Math.floor ( gallery.size [ 1 ] / 2 ) + 'px' ; 
		gallery.prev.style.left = '5px'; 
		gallery.prev.style.display = 'none'; 
		liwe.events.add ( gallery.prev, 'mousedown', function ( ev )  { gallery.display_prev ( ev ); } );
	
		gallery.next = document.createElement ( 'div' );
		gallery.next.className = 'gallery_next';
		gallery.next.style.top = Math.floor ( gallery.size [ 1 ] / 2 ) + 'px'; 
		gallery.next.style.right = '5px'; 
		if ( gallery.items.count() == 1 ) gallery.next.style.display = 'none'; 
		liwe.events.add ( gallery.next, 'mousedown', function ( ev )  { gallery.display_next ( ev ); } );

		gallery.player = document.createElement ( 'div' )
		gallery.player.className = 'gallery_play';

		gallery.player.style.display = 'none';
		gallery.player.style.top = Math.floor ( gallery.size [ 1 ] / 2 ) - Math.floor ( gallery.player_size [ 'h' ] / 2 )  + 'px'; 
		gallery.player.style.left = Math.floor ( gallery.size [ 0 ] / 2 ) - Math.floor ( gallery.player_size [ 'w' ] / 2 ) + 'px';
		
		gallery.controls.appendChild ( gallery.head );
		gallery.controls.appendChild ( gallery.next );
		gallery.controls.appendChild ( gallery.player );
		gallery.controls.appendChild ( gallery.prev );
		gallery.controls.appendChild ( gallery.thumb );
		// }}}

		gallery.container.appendChild ( gallery.images );
		gallery.container.appendChild ( gallery.controls );

		gallery.video_embed  = undefined;
		gallery.dest_div.appendChild ( gallery.container );

		gallery.arrow_thumb.render ( gallery.thumb_arrow_id ); 
		gallery.dest_div.style.overflow="hidden";

		var h = liwe.dom.get_size ( $( gallery.thumb_id ) ) [ 1 ];
		var thumb_tab = $c( 'div', 'gallery_thumb_tab', gallery.dest_div ) [ 0 ];
		//var thumb_tab_h = liwe.dom.get_style ( thumb_tab, 'clientHeight' ); 
		var thumb_tab_h = thumb_tab.clientHeight;
		$( gallery.thumb_id ).style.bottom = ( thumb_tab_h - h ) + 'px';
		//liwe.fx.animate ( gallery.thumb_id , { bottom : , left : '0px' }, null, 0, 'ease-in' );	
		gallery.thumb_showed = false;

		liwe.fx.set_opacity ( gallery.controls.id , 0 );
		if ( ! gallery._ie )
		{
			liwe.fx.set_opacity ( gallery.imgcnt[ 1 ].id , 0 );
			liwe.fx.set_opacity ( gallery.info [ 1 ].id , 0 );
		};

		gallery.controls._is_show = false;
		var el = $el ('move_prev_' +  gallery.thumb_id );
		el.parentNode.removeChild ( el );
		var el = $el ('move_next_' +  gallery.thumb_id );
		el.parentNode.removeChild ( el );
	};
	//}}}
	//{{{gallery.img_caricata = function ( el )
	gallery.img_caricata = function ( el )
	{
			
		var w, h, size = liwe.dom.get_body_size ();
		w = size [ 0 ];
		h = size [ 1 ];
		
		if ( ! gallery.dest_div._is_full  )
		{
			w = gallery.size [ 0 ];
			h = gallery.size [ 1 ];
		};
		
		el.style.height = h + 'px';
		el.style.left = ( ( w / 2 ) - el.width / 2 ) + "px";
		gallery._switch();
	};
	//}}}
	//{{{ gallery._switch this function crossfading titile and images it's was called when change src
	gallery._switch = function ()
	{
		var info = gallery.info [ gallery._switch_id ];
		var imgcnt = gallery.imgcnt [ gallery._switch_id ];
		if ( gallery._ie )
		{
			info.style.display = 'none';
			imgcnt.style.display = 'none';
		}
		else
		{
			liwe.fx.fade_out ( info.id  );
			liwe.fx.fade_out ( imgcnt.id );
		}

		gallery._switch_id = 1- gallery._switch_id;
		info = gallery.info [ gallery._switch_id ];
		imgcnt = gallery.imgcnt [ gallery._switch_id ];

		if ( gallery._ie )
		{
			info.style.display = 'block';
			imgcnt.style.display = 'block';
		}
		else	
		{
			liwe.fx.fade_in ( info.id );
			liwe.fx.fade_in ( imgcnt.id );
		}
	

	};
	///}}}
	//{{{ gallery.display_item this function set title, alt and src  width the informations contains in gallery.items [ id ]
	gallery.display_item = function ( sb, elem, pos )
	{
		var id = 0;
		if ( elem  ) 
		{
			id =  elem._pos -1;
		}else{
			id = pos
		};
		if ( gallery.img_current == id ) return;
		var item =  gallery.items [ id ] ;

		var info = gallery.info [ 1 - gallery._switch_id ]; 
		
		info.innerHTML = String.formatDict ( WWL.gallery.templates [ 'info' ] , 
					{
						'alt' : item.alt,
						'title' : item.title
					} );
		
		var img_to = $(  gallery.name + '_img_' + ( 1 - gallery._switch_id ) );
		//restore configuration
		img_to.style.display = 'block';
		var size = gallery._get_size();
		gallery.player.style.display = 'block';
		gallery.thumb.style.display = 'block';
		gallery.controls.style.height = size [ 1 ] + 'px';



		img_to.src = item.src;
		gallery.img_current = id ;
		gallery.prev.style.display = 'block';
		gallery.next.style.display = 'block';

		gallery.player.style.display = 'none';
		var _cnt = $(  gallery.name + '_imgcnt_' +  gallery._switch_id   ) ;
		if (  gallery.video_embed )  
		{
			liwe.dom.remove_element( gallery.video_embed, _cnt );
			gallery.video_embed = null;
		}

		liwe.events.del ( gallery.player , 'click', gallery.youtube_play );

		if ( item.get ( 'youtube', null ) )
		{
			gallery.player.style.display = 'block';
			liwe.events.add ( gallery.player , 'click', gallery.youtube_play );
			//add youtube element
			_cnt = $(  gallery.name + '_imgcnt_' + ( 1 - gallery._switch_id )  ) ;
			gallery.video_embed = document.createElement ( 'div' )
			gallery.video_embed.id = gallery.name + '_video_embed'
			_cnt.appendChild ( gallery.video_embed );
			
		};

		if ( id == 0 )  gallery.prev.style.display = 'none'; 
		if ( id == gallery.items.count() -1 )  gallery.next.style.display = 'none'; 
	};
	//}}}
	//{{{ gallery.display_prev set previsius id if is the fist the id will set to the last
	gallery.display_prev = function ( ev )
	{
		WWL.arrowbox.move_prev ( 'gallery_thumb_' + gallery.name )
	}
	//}}}
	//{{{ gallery.display_prev set next id if is the last the id will set to the first
	gallery.display_next = function ( ev )
	{
		WWL.arrowbox.move_next ( 'gallery_thumb_' + gallery.name )
	}
	//}}}
	//{{{gallery.show_controls set to 1 the opacity of the controls for 3000ms then the opacity is set to 0
	gallery.show_controls = function ( ev )
	{
		if ( gallery.t_controls ) clearTimeout ( gallery.t_controls );
		
		if ( !gallery.controls._is_show )
		{
			liwe.fx.fade_in ( gallery.controls.id , function ()
			{
				gallery.controls.style.display='block';
				gallery.controls._is_show = true;
			});
			
		}
	
		gallery.t_controls = setTimeout ( function ()
		{
			liwe.fx.fade_out ( gallery.controls.id , function () 
			{ 
				gallery.controls.style.display='none';
				gallery.controls._is_show = false;
			} );
		} , 3000 ) ;
	};
	//}}}
	//{{{ gallery.thumbnails events add on tab's when click show or hide the arrowbox of the thumbnails 
	gallery.thumbnails =  function ( ev )
	{
		if ( gallery.thumb_showed )
		{
			var h = liwe.dom.get_size ( $('gallery_thumb_arrow_' + gallery.name ) ) [ 1 ];
			liwe.dom.del_class ( gallery.thumb_tab, 'down' );
			liwe.dom.add_class ( gallery.thumb_tab, 'up' );
			liwe.fx.animate ( gallery.thumb_id , { bottom :  - h + 'px' }, null, 50, 'ease-in' );
		}else{
			liwe.dom.del_class ( gallery.thumb_tab, 'up' );
			liwe.dom.add_class ( gallery.thumb_tab, 'down' );
			liwe.fx.animate ( gallery.thumb_id , { bottom : '0px' }, null, 50, 'ease-in' );
		};
		gallery.thumb_showed = ! gallery.thumb_showed 
	};
	//}}}
	//{{{ gallery.toggle_full_screen display gallery full screen or origina size if is full screen
	gallery.toggle_full_screen = function ( ev )
	{

		var w, h, size = liwe.dom.get_body_size ();
		w = size [ 0 ];
		h = size [ 1 ];

		var dd = gallery.dest_div;
		if (  gallery.dest_div._is_full  )
		{
			// Torno alla modalita' NON fullscreen
			w = gallery.size [ 0 ];
			h = gallery.size [ 1 ];

			if ( !dd._position.get ( 'position' ) ) 
			{
				delete dd.style [ 'position' ];
			}else{
				dd.style.position = dd._position.position;
			};

			dd.style.top = dd._position.get ( 'top' );
			dd.style.bottom = dd._position.get ( 'bottom' );
			dd.style.left = dd._position.get ( 'left' );
			dd.style.right = dd._position.get ( 'right' );
			/*
			if ( !dd._position ) 
			{
				delete dd.style [ 'position' ];
			}else{
				dd.style.position = dd._position;
			};
			delete dd.style [ 'top' ];
			delete dd.style [ 'bottom' ];
			delete dd.style [ 'left' ];
			delete dd.style [ 'right' ];
			*/
			dd.style.width = w + 'px';
			dd.style.height = h + 'px';
			dd.style.zIndex = dd._zindex;
			liwe.dom.del_class ( gallery.set_screen, 'page' );
			liwe.dom.add_class ( gallery.set_screen, 'full' );
			
		}else{
			dd.style.top = '0px';
			dd.style.bottom = '0px';
			dd.style.left = '0px';
			dd.style.right =  '0px';
			dd.style.position = 'absolute';
			dd.style.zIndex = gallery._zindex_max;

			setTimeout ( function () { dd.style.width = '100%'; dd.style.height = '100%'; dd.style.position = 'fixed'; }, 10 );
			liwe.dom.del_class ( gallery.set_screen, 'full' );
			liwe.dom.add_class ( gallery.set_screen, 'page' );
		};
	


		gallery.images.style.width = w + 'px';
		gallery.images.style.height= h + 'px';
		gallery.controls.style.width = w + 'px';
		gallery.controls.style.height= h + 'px';
	
			
		var img = $( gallery.name + '_img_0' );

		img.style.height = h + 'px';
		
		img.style.left = ( ( w / 2 ) - img.width / 2 ) + "px";
		
		img = $( gallery.name + '_img_1');
		// img.style.width = w + 'px';
		img.style.height= h + 'px';

		img.style.left = ( ( w / 2 ) - img.width / 2 ) + "px";
		

		//prev and next player
		gallery.prev.style.top = Math.floor ( h / 2 ) + 'px' ; 
		gallery.next.style.top = Math.floor ( h / 2 ) + 'px' ; 

		gallery.player.style.top = Math.floor ( h / 2 ) - Math.floor ( gallery.player_size [ 'h' ] / 2 )  + 'px'; 
		gallery.player.style.left = Math.floor ( w / 2 ) - Math.floor ( gallery.player_size [ 'w' ] / 2 ) + 'px';

		//arrowBox

		gallery.arrow_thumb.set_size  ( w - 50, gallery.thumb_size [ 'h' ]  );
		gallery.arrow_thumb.render ( gallery.thumb_arrow_id ); 
		
		var el = $el ('move_prev_' +  gallery.thumb_id );
		el.parentNode.removeChild ( el );
		var el = $el ('move_next_' +  gallery.thumb_id );
		el.parentNode.removeChild ( el );

		gallery.dest_div._is_full = 1- gallery.dest_div._is_full; 
	};
	//}}}
	//{{{gallery._get_size = function ()
	gallery._get_size = function ()
	{
		var size = gallery.size;

		if ( gallery.dest_div._is_full  )
		{
			// Torno alla modalita' NON fullscreen
			size = liwe.dom.get_body_size ();
		};
		return size; 
	};
	//}}}
	//{{{gallery.youtube_play = function ()
	gallery.youtube_play = function ()
	{
		var size = gallery._get_size();
		var _img = $(  gallery.name + '_img_' + ( gallery._switch_id )  ) ;

		_img.style.display = 'none';

		var item = gallery.items [ gallery.img_current ] ;

		var obj = document.createElement ( "object" );
		obj.setAttribute ( "type","application/x-shockwave-flash" );
		obj.setAttribute ( "width", size [ 0 ] );
		obj.setAttribute ( "height",size [ 1 ] );
		obj.setAttribute ( "wmode", "opaque" );

		obj.setAttribute ( "data","http://www.youtube.com/v/" + item [ 'youtube' ] + "&autoplay=1" );

		var par1 = document.createElement ( "param" );
		par1.setAttribute ( "name", "movie" );
		par1.setAttribute ( "value", "http://www.youtube.com/v/" + item [ 'youtube' ] + "&autoplay=1" );
		par1.setAttribute ( "wmode", "opaque" );
		obj.appendChild ( par1 );

		gallery.video_embed.appendChild ( obj );

		gallery.player.style.display = 'none';
		gallery.thumb.style.display = 'none';
		gallery.controls.style.height = size [ 1 ] - 100  + 'px';
		
		return;
	};
	//}}}
	//{{{gallery.media_manager = function ( lst_media, dest_div )
	gallery.media_manager = function ( lst_media, dest_div )
	{
		var src = null;
		var data = null;
		lst_media.iterate ( function ( media )
		{
			data = null;
			src = "/site/media_manager/"+ media [ 'kind' ] +"/full/" + media [ 'id_media' ] + ".jpg";
			src_thumb = "/site/media_manager/"+ media [ 'kind' ] +"/icon/" + media [ 'id_media' ] + ".jpg";
			if ( media [ 'kind' ] == 'youtube' ) data = media [ 'data' ] ;
			gallery.add_item ( src, media [ 'descr' ], media [ 'descr' ], src_thumb, data ); 
		});
		gallery.render ( dest_div );
			
	};

	return gallery;
	//}}}
};

//{{{WWL.gallery.get_instance = function ( instance_name )
WWL.gallery.get_instance = function ( instance_name )
{
	return WWL.get_instance ( "gallery", instance_name );
};
//}}}
//{{{WWL.gallery.display_item = function ( name, id )
WWL.gallery.display_item = function ( name, id )
{
	var g = WWL.gallery.get_instance ( name );
	g.display_item ( id );	
};
//}}}

//{{{gallery_img = function ( src, alt, title, thumb_src, youtube  )
var gallery_img = function ( src, alt, title, thumb_src, youtube  )
{
	var self = this;

	this.src = src;
	this.alt = alt;
	this.title = title;
	this.className =  'gallery_img_img';
	this.youtube = youtube;

	this.thumb_w = 100;
	this.thumb_h = 50;

	this._use_size = true;

	if ( ! thumb_src ) 
	{
		this.thumb_src = src; 
	}
	else
	{
		this.thumb_src = thumb_src; 
		this._use_size = false;
	}

	this.set_thumb_size = function ( w , h )
	{
		self.thumb_w = w;
		self.thumb_h = h;
	};

	this.set_thumb_src =  function ( src )
	{
		self.thumb_src = src;
	};
	
	this.get_img_html = function ( thumb )
	{
		var img = self.get_img ( thumb );
		if ( self._use_size )
		{
			var res= "<img class='%(class)s' width='%(w)s' height='%(h)s' alt='%(alt)s' title='%(title)s' src='%(src)s'>";
			var dict = { 'w' : img.width, 'h' : img.height, 'alt': img.alt, 'title' : img.title , 'src' : img.src, 'class' : img.className  } ;
		}
		else
		{
			var res= "<img class='%(class)s' alt='%(alt)s' title='%(title)s' src='%(src)s'>";
			var dict = { 'alt': img.alt, 'title' : img.title , 'src' : img.src, 'class' : img.className  } ;
			
		};
				
		return String.formatDict ( res, dict );
		
	};
	
	this.get_img = function ( thumb, cback )
	{
		var img = document.createElement ( 'img' );

		if ( cback )
		{
			liwe.events.add ( img , 'load', function () { cback (img);} );
		};

		img.alt = self.alt;
		img.title = self.title
		img.className =  self.className;
		if ( thumb ) 
		{
			img.width = self.thumb_w;
			img.height = self.thumb_h;
			img.src = self.thumb_src;
			img.className =  'gallery_thumbnail';
			return img;
		};
		img.src  = self.src;
		return img;
	};	

};
//}}}
